﻿using System;
using Ayatta.Service.Product.Index.Domain;

namespace Ayatta.Service.Product.Index.Extension
{
    /// <summary>
    /// 索引目录扩展
    /// </summary>
    internal static class IndexDiretoryExtension
    {
        /// <summary>
        /// 索引目录主从切换
        /// </summary>
        /// <param name="target">索引目录</param>
        /// <returns></returns>
        internal static IndexDirectory Switch(this IndexDirectory target)
        {
            return target == IndexDirectory.Master ? IndexDirectory.Slave : IndexDirectory.Master;
        }

        /// <summary>
        /// 获取索引目录名
        /// </summary>
        /// <param name="target"></param>
        /// <returns></returns>
        internal static string Path(this IndexDirectory target)
        {
            var baseDir = AppDomain.CurrentDomain.BaseDirectory + @"IndexDirectory\";
            switch (target)
            {
                case IndexDirectory.Master: return baseDir + @"Master";
                case IndexDirectory.Slave: return baseDir + @"Slave";
                default: return baseDir + @"Master";
            }
        }
    }

}